<template>
  <div class="d-flex" v-if="finish">
    <div v-html="arr"></div>
  </div>
  <div v-else>数据加载中...请耐心等待</div>
  
</template>

<script setup lang="ts">
definePageMeta({
  layout: "article",
});
import { onMounted, ref } from "vue";
const finish = ref(false)








let arr = ref();
const route = useRoute();
console.log(route,'获取当前路由的参数');

//寻找第三个 / 的下标
const text = decodeURI(route.fullPath);
let slashIndex = -1;
let count = 0;

// 循环查找斜杠，直到找到第三个或者遍历完整个字符串
while (count < 3 && (slashIndex = text.indexOf("/", slashIndex + 1)) !== -1) {
  count++;
}
let url12 = text.substring(slashIndex + 1, slashIndex + 1 + 12); //输出第三个斜杠的下标位置
console.log('url12',url12);





let result: any = await useFetch("/api/post/getnewsitem", {
  method: "POST",
  body: { url12:url12},
});
// console.log(url12, result, "发送清华求");

onMounted(() => {
  
  arr.value = result.data.value?.data[0].content;
  finish.value = true
  

});

</script>

<style scoped></style>
